package com.jinghua.treatment.wechat.biz;

import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.jinghua.treatment.tools.DaYuSMSUtil;
import com.jinghua.treatment.tools.StringUtil;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 短信业务
 */
@Service
public class SMSBiz {

    public String sendSMSValicode(String phone){
        Map params = new HashMap();
        params.put("phone",phone);
        params.put("signName","杏林名家");
        params.put("templateCode","SMS_132991282");
        String code  = StringUtil.randomStringNumber(6);
        params.put("templateParam","{\"code\":\""+code+"\"}");
        try {
            SendSmsResponse sendSmsResponse  = DaYuSMSUtil.sendSms(params);
            System.out.println(sendSmsResponse.getMessage());
        } catch (ClientException e) {
            e.printStackTrace();
        }
        return code;
    }
}
